<template>
	<view class="top_box">
		<!-- 轮播图 -->
		<view class="uni-margin-wrap">
			<swiper class="swiper" circular :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval"
				:duration="duration">
				<swiper-item v-for="(item,index) in background" :key="index">
					<view class="swiper-item">{{item}}</view>
				</swiper-item>
			</swiper>
		</view>

		<!-- 小卡片 -->
		<view class="grid_card">
			<div class="item" v-for="(item,index) in cardList" :key="index">
				<img :src=item.url class="grid_card_img" />
				<text>{{item.text}}</text>
			</div>
		</view>
	</view>

	<!-- 导航栏 -->



	<!-- 公告 -->
	<view class="two_columns notice">
		<view class="nav">
			<view class="content_box">
				<text class="left">公告信息展示</text>
				<text class="right">查看更多</text>
			</view>
		</view>
		<view class="card_box">
			<view class="item" v-for="(item,index) in notice" :key="index" @click="toNoticePage">
				<view class="title" style="font-sise: 22rpx;">{{item.title+(index+1)}}</view>
				<view class="detail">{{item.detail}}</view>
				<time class="date">{{item.date}}</time>
			</view>
		</view>
	</view>

	<!-- 运动教程展示 -->
	<view class="three_columns sport">
		<view class="nav">
			<view class="content_box">
				<text class="left">运动教程展示</text>
				<text class="right">查看更多</text>
			</view>
		</view>
		<view class="card_box">
			<view class="item" v-for="(item,index) in sport" :key="index">
				<text class="title">{{item.title+(index+1)}}</text>
				<image class="img" :src="item.img" />
			</view>
		</view>
	</view>

	<!-- 健康食谱展示 -->
	<view class="three_columns healthy_recipes">
		<view class="nav">
			<view class="content_box">
				<text class="left">健康食谱展示</text>
				<text class="right">查看更多</text>
			</view>
		</view>
		<view class="card_box">
			<view class="item" v-for="(item,index) in healthyRecipes" :key="index">
				<text class="title">{{item.title+(index+1)}}</text>
				<image class="img" :src="item.img" />
			</view>
		</view>
	</view>

	<!-- 健康贴士展示 -->
	<view class="two_columns healthTips">
		<view class="nav">
			<view class="content_box">
				<text class="left">健康贴士展示</text>
				<text class="right">查看更多</text>
			</view>
		</view>
		<view class="card_box" @click="toTipsPage">
			<view class="item" v-for="(item,index) in healthTips" :key="index">
				<view class="title" style="font-sise: 22rpx;">{{item.title+(index+1)}}</view>
				<view class="detail">{{item.detail}}</view>
				<time class="date">{{item.date}}</time>
			</view>
		</view>
	</view>

	<!-- 药品信息展示 -->
	<view class="three_columns drug_info">
		<view class="nav">
			<view class="content_box">
				<text class="left">药品信息展示</text>
				<text class="right">查看更多</text>
			</view>
		</view>
		<view class="card_box">
			<view class="item" v-for="(item,index) in medicineInfo" :key="index">
				<text class="title">{{item.name+(index+1)}}</text>
				<image class="img" :src="item.img" />
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 轮播图
				background: ['color1', 'color2', 'color3'],
				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				duration: 500,

				// 小卡片
				cardList: [{
						url: '../../static/center/sp.png',
						text: '健康食谱'
					},
					{
						url: '../../static/center/yp.png',
						text: '药品信息'
					},
					{
						url: '../../static/center/yd.png',
						text: '运动教程'
					},
					{
						url: '../../static/center/jk.png',
						text: '健康贴士'
					},
				],

				// 公告
				notice: [{
					title: '公告标题',
					detail: '公告详情',
					date: '2023-05-06'
				}, {
					title: '公告标题',
					detail: '公告详情',
					date: '2023-05-06'
				}, {
					title: '公告标题',
					detail: '公告详情',
					date: '2023-05-06'
				}, {
					title: '公告标题',
					detail: '公告详情',
					date: '2023-05-06'
				}],
				// 运动
				sport: [{
					title: '标题',
					img: '/static/logo.png'
				}, {
					title: '标题',
					img: '/static/logo.png'
				}, {
					title: '标题',
					img: '/static/logo.png'
				}, {
					title: '标题',
					img: '/static/logo.png'
				}, ],
				// 健康食谱
				healthyRecipes: [{
					title: '食谱标题',
					img: '/static/logo.png'
				}, {
					title: '食谱标题',
					img: '/static/logo.png'
				}, {
					title: '食谱标题',
					img: '/static/logo.png'
				}, {
					title: '食谱标题',
					img: '/static/logo.png'
				}, ],
				// 健康贴士
				healthTips: [{
					title: '贴hi标题',
					detail: '贴士详情',
					date: '2023-06-06'
				}, {
					title: '贴hi标题',
					detail: '贴士详情',
					date: '2023-06-06'
				}, {
					title: '贴hi标题',
					detail: '贴士详情',
					date: '2023-06-06'
				}, {
					title: '贴hi标题',
					detail: '贴士详情',
					date: '2023-06-06'
				}, ],
				// 药品信息
				medicineInfo: [{
					name: '药品名称',
					img: '/static/logo.png'
				}, {
					name: '药品名称',
					img: '/static/logo.png'
				}, {
					name: '药品名称',
					img: '/static/logo.png'
				}, {
					name: '药品名称',
					img: '/static/logo.png'
				}, ],
			}
		},
		onLoad() {

		},
		methods: {
			toNoticePage() {
				uni.navigateTo({
					url: '/pagesTwo/NoticePage/NoticePage'
				});
			},
			toTipsPage() {
				uni.navigateTo({
					url: '/pagesTwo/TipsPage/TipsPage'
				});
			}
		}
	}
</script>

<style lang="scss">
	image {
		vertical-align: middle;
	}

	.top_box {
		margin: 0 8rpx;

		.uni-margin-wrap {
			width: 690rpx;
			width: 100%;
			background-color: #F7FCE9;
		}

		.swiper {
			height: 300rpx;
		}

		.swiper-item {
			display: block;
			height: 300rpx;
			line-height: 300rpx;
			text-align: center;
		}
	}

	// 卡片
	.grid_card {
		margin: 20rpx 0;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.item {
			color: black;
			font-size: 13px;
			width: 164rpx;
			height: 156rpx;
			border-radius: 5px;
			text-align: center;
			background-color: #F7FCE9;
			display: flex;
			flex-direction: column;
			flex-wrap: wrap;
			align-content: space-evenly;
			justify-content: center;

			.grid_card_img {
				width: 70rpx;
				margin: 15rpx auto;
				height: 70rpx;
			}
		}
	}

	// 导航栏
	.nav {
		.content_box {
			margin-top: 40rpx;
			height: 35rpx;
			line-height: 35rpx;
			padding: 8px 3px 8px 18px;
		}

		.left {
			float: left;
		}

		.right {
			float: right;
			color: #C2C2C2;
			font-size: 25rpx;
		}
	}

	.two_columns {
		.card_box {
			padding: 16rpx;
			display: grid;
			grid-gap: 16rpx;
			grid-template-columns: auto auto;

			.item {
				border: #F7FCE9 1px solid;
				border-radius: 10rpx;
				line-height: 50rpx;
				padding-left: 12rpx;

				.title {
					font-weight: 550;
					font-size: 24rpx;
				}

				.detail {
					font-size: 23rpx;
					color: #888;
					;
				}

				.date {
					color: #888;
					padding-left: 20rpx;
					font-size: 20rpx;
				}
			}
		}
	}

	// 药品信息展示
	// 展示
	.three_columns {

		// 药品信息卡片
		.card_box {
			display: grid;
			grid-template-columns: auto auto auto;
			grid-gap: 16rpx;
			border: #F7FCE9 1px solid;

			.item {
				height: 200rpx;
				padding: 0 10rpx 10rpx;
				overflow: hidden;
				display: flex;
				flex-wrap: wrap;
				align-content: space-between;
				justify-content: center;
				background-color: #fff;

				.title {
					color: black;
					font-size: 12px;
				}

				image {
					width: 100%;
					height: 75%;
					border-radius: 48%;
				}
			}
		}
	}
</style>